<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ include file="../common.inc" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<link href="./css/style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="./js/calendar.js"></script>
<script type="text/javascript" language="javascript">
<!--
	function checkForm(){
		
		var customerName = document.getElementById("customerName");
		var salePersonId = document.getElementById("salePersonId");
		var industryId = document.getElementById("industryId");
		var areaId = document.getElementById("areaId");
		var requireDesc = document.getElementById("requireDesc");
		var startcontractDate = document.getElementById("startcontractDate");
		var endcontractDate = document.getElementById("endcontractDate");
		var startbackDate = document.getElementById("startbackDate");
		var endbackDate = document.getElementById("endbackDate");
		var backCostDesc = document.getElementById("backCostDesc");
		if(startcontractDate.value != ''){
			if(endcontractDate.value == ''){
				alert("请选择建档结束日期！");
				return false;
			}
		}
		if(endcontractDate.value != ''){
			if(startcontractDate.value == ''){
				alert("请选择建档开始日期！");
				return false;
			}
		}
		if(startcontractDate.value != '' && endcontractDate.value != ''){
			var d1 = (startcontractDate.value).replace("-","/");
			var d2 = (endcontractDate.value).replace("-","/");
			if(Date.parse(d1) - Date.parse(d2) > 0){
				alert("建档开始日期不能比建档结束日期早，请重新选择建档开始日期！");
				return false;
			}
		}
		
		if(startbackDate.value != ''){
			if(endbackDate.value == ''){
				alert("请选择最后联系结束日期！");
				return false;
			}
		}
		if(endbackDate.value != ''){
			if(startbackDate.value == ''){
				alert("请选择最后联系开始日期！");
				return false;
			}
		}
		if(startbackDate.value != '' && endbackDate.value != ''){
			var d1 = (startbackDate.value).replace("-","/");
			var d2 = (endbackDate.value).replace("-","/");
			if(Date.parse(d1) - Date.parse(d2) > 0){
				alert("最后联系开始日期不能比最后联系结束日期早，请重新选择最后联系开始日期！");
				return false;
			}
		}
		
		if(salePersonId.value == '' && customerName.value == '' 
			&& industryId.value == '0' && areaId.value == '0' 
			&& backCostDesc.value == '' && requireDesc.value == '' 
			&& startcontractDate.value == '' && endcontractDate.value == '' 
			&& startbackDate.value == '' && endbackDate.value == ''){
			alert("请输入查询条件！");
			return false;
		}
		return true;
	}
	
	function queryCustomer(){
		if(checkForm()){
			var customerName = document.getElementById("customerName").value;
			var salePerson = document.getElementById("salePersonId").value;
			var industryId = document.getElementById("industryId").value;
			var areaId = document.getElementById("areaId").value;
			var requireDesc = document.getElementById("requireDesc").value;
			var startcontractDate = document.getElementById("startcontractDate").value;
			var endcontractDate = document.getElementById("endcontractDate").value;
			var startbackDate = document.getElementById("startbackDate").value;
			var endbackDate = document.getElementById("endbackDate").value;
			var backCostDesc = document.getElementById("backCostDesc").value;
			
			var values = customerName + "," + salePerson + "," + industryId + "," + areaId + "," + requireDesc + ",";
			values += startcontractDate + "," + endcontractDate + "," + startbackDate + "," + endbackDate + "," + backCostDesc;
			
			window.returnValue = values;
			self.close();
		}
	}
	
-->
</script>
</head>
<body><br>
	<div class="tools">
		<input class="btn1" type="button" value="确 定" onclick="queryCustomer()"/>&nbsp;&nbsp;
		<input class="btn1" type="button" value="取 消" onclick="window.close();"/>&nbsp;&nbsp;
	</div>
	
<table class="table1">
	<tr>
		<td>
			<table class="table_input" cellpadding="0" cellspacing="0" style="margin: 0 0 0 40px;">
				<tr>
					<td><!-- 客户名称 -->
						客户名称:
					</td>
					<td><input id="customerName" name="customerName" class="input_long" type="text"/></td>
				</tr>
					<!--<tr>
					<td> 客户名称 
						<c:choose>
							<c:when test="${language == 2}">${records['12'].currentRecordEn}：</c:when>
							<c:otherwise>${records['12'].currentRecord}：</c:otherwise>
						</c:choose>
					</td>
					<td><input id="customerName" name="customerName" class="input_long" type="text"/></td>
				</tr>
				-->
				<tr>
			
					<td width="20%">销售代表：</td>
					<td>
						<select id="salePersonId" name="salePersonId">
							<option value="">----------请选择----------</option>
							<c:forEach var="user" items="${users}">
								<option value="${user.id}">${user.userName}</option>
							</c:forEach>
						</select>
					</td>
				</tr>
				<tr>
					<td width="20%"><!-- 行业 -->
						行业：
					</td>
					<td width="">
						<select id="industryId" name="industryId">
							<option value="">----------请选择----------</option>
							<c:forEach var="range" items="${ranges['110']}">
							<option value="${range.id}">${range.rangeValue}</option>
							</c:forEach>
						</select>
					</td>
				</tr>
				<tr>
					<td width=""><!-- 区域 -->
						区域：
					</td>
					<td width="">
						<select id="areaId" name="areaId">
							<option value="">----------请选择----------</option>
							<c:forEach var="range" items="${ranges['111']}">
							<option value="${range.id}">${range.rangeValue}</option>
							</c:forEach>
						</select>
					</td>
				</tr>
				<!-- 
				<tr>
					<td width="20%">联系人：</td>
					<td><input class="input_long" type="text"/></td>
				</tr>
				<tr>
					<td width="20%">销售代表：</td>
					<td><input class="input_long" type="text"/></td>
				</tr>
				 -->
				
				
				<tr>
					<td width="20%">签约时间：</td>
					<td>
						<input id="startcontractDate" name="startcontractDate" class="input1" type="text" onclick="calendar(this,'yyyy-MM-dd');" readonly="readonly"/>--
						<input id="endcontractDate" name="endcontractDate" class="input1" type="text" onclick="calendar(this,'yyyy-MM-dd');" readonly="readonly"/>
					</td>
				</tr>
				<tr>
					<td width="20%">回款时间：</td>
					<td>
						<input id="startbackDate" name="startbackDate" class="input1" type="text" onclick="calendar(this,'yyyy-MM-dd');" readonly="readonly"/>--
						<input id="endbackDate" name="endbackDate" class="input1" type="text" onclick="calendar(this,'yyyy-MM-dd');" readonly="readonly"/>
					</td>
				</tr>
				<tr>
					<td width=""><!-- 需求描述 -->
						需求描述：
					</td>
					<td><input id="requireDesc" name="requireDesc" class="input_long" type="text"/></td>
				</tr>
				<tr>
					<td width="">
						客户备注：
					</td>
					<td><input id="backCostDesc" name="backCostDesc" class="input_long" type="text"/></td>
				</tr>
			</table>
		</td>
	</tr>
</table>	
</body>
</html>